class Array
  
  def intersection(enum)
    inter = []
    self.each { |e| inter << e if enum.include?(e) }
    enum.each { |e| inter << e if self.include?(e) }
    inter.uniq
  end
  
  def inter_ids(enum)
    inter = []
    enum_ids = enum.collect { |e| e.id }
    self_ids = self.collect { |e| e.id }
    
    enum.each { |e| inter << e if self_ids.include?(e.id) }
    enum.each { |e| inter << e if enum_ids.include?(e.id) }
    inter.uniq
  end
end